<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
 <head>
  <title>E卡返点</title>
  <t:base type="jquery,easyui,tools,DatePicker"></t:base>
 <link type="text/css" href="plug-in/Validform/css/metrole/style.css" rel="stylesheet">
 <link type="text/css" href="plug-in/Validform/css/metrole/tablefrom.css" rel="stylesheet">
 <script src="plug-in/Validform/js/Validform_v5.3.1_min_zh-cn.js" type="text/javascript"></script>
 <script src="plug-in/Validform/js/Validform_Datatype_zh-cn.js" type="text/javascript"></script>
 <script src="plug-in/Validform/js/datatype_zh-cn.js" type="text/javascript"></script>
 <script src="plug-in/Validform/plugin/passwordStrength/passwordStrength-min.js" type="text/javascript"></script>
 </head>
 <body style="overflow-y: auto" scroll="no">
 <form id="rebate_return" action="mallEcardRebateController.do?rebatereturn" method="post">
	 <input type="hidden" value="${rebate.id}" name="id">
	 <table style="width: 100%" cellpadding="0" cellspacing="1" class="formtable">
	 <c:set value="0" var="totalMoney" />
	 <c:set value="0" var="actualPayTotalMoney" />
	  <c:forEach var="order" items="${orderDetail}" varStatus="mapStatus">
		  <c:set  var="totalMoney"  value="${totalMoney + order.key.paymoney}"/>
		  <c:set  var="actualPayTotalMoney"  value="${actualPayTotalMoney + order.key.actualPayMoney}"/>
		 <tr><td colspan="6" style="text-align: center">订单信息</td></tr>
		 <tr>
			 <td align="right">
				 <label class="Validform_label">
					${mapStatus.index + 1}:&nbsp;&nbsp;&nbsp;&nbsp;订单编号:
				 </label>
			 </td>
			 <td class="value">
				 <span class="">${order.key.orderno}</span>
			 </td>
			 <td align="right">
				 <label class="Validform_label">
					 所属店铺:
				 </label>
			 </td>
			 <td class="value">
				 <span class="">${order.key.shop.shopname}</span>
			 </td>
			 <td align="right">
				 <label class="Validform_label">
					 订单类型:
				 </label>
			 </td>
			 <td class="value">
				<span class="">
					<input type="hidden" id="order_type" value="${order.key.ordertype}">
					<c:if test="${order.key.ordertype == 0}">
						线上商城订单
					</c:if>
					<c:if test="${order.key.ordertype == 1}">
						本地服务订单
					</c:if>
					<c:if test="${order.key.ordertype == 2}">
						在线充值服务订单
					</c:if>
				</span>
			 </td>
		 </tr>
		 <tr>
			 <td align="right">
				 <label class="Validform_label">
					 商品金额:
				 </label>
			 </td>
			 <td class="value">
				 <span class="">${order.key.productmoney}</span>
			 </td>
			 <td align="right">
				 <label class="Validform_label">
					 订单金额:
				 </label>
			 </td>
			 <td class="value">
				 <span class="">${order.key.paymoney}</span>
			 </td>
			 <td align="right">
				 <label class="Validform_label">
					 实际支付金额:
				 </label>
			 </td>
			 <td class="value">
				<span class="">${order.key.actualPayMoney}</span>
			 </td>
		 </tr>
		 <tr>
			 <td align="right">
				 <label class="Validform_label">
					 买家:
				 </label>
			 </td>
			 <td class="value">
				 <span class="">${order.key.user.fullname}</span>
			 </td>
			 <td align="right">
				 <label class="Validform_label">
					 创建时间:
				 </label>
			 </td>
			 <td class="value">
				 <span class=""><fmt:formatDate value='${order.key.createtime}' type="date" pattern="yyyy-MM-dd HH:mm:ss"/></span>
			 </td>
			 <td align="right">
				 <label class="Validform_label">
					 支付时间:
				 </label>
			 </td>
			 <td class="value">
				 <span class=""><fmt:formatDate value='${order.key.paytime}' type="date" pattern="yyyy-MM-dd HH:mm:ss"/></span>
			 </td>
		 </tr>
		 <tr><td colspan="6" style="text-align: center">订单详情</td></tr>
		 <c:forEach var="detail" items="${order.value}" varStatus="status">
			 <%--线上商城订单--%>
			 <c:if test="${order.key.ordertype == 0}">
				 <tr>
					 <td align="right">
						 <label class="Validform_label">
							 商品名称:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.productname}</span>
					 </td>
					 <td align="right">
						 <label class="Validform_label">
							 商品编码:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.productcode}</span>
					 </td>
					 <td align="right">
						 <label class="Validform_label">
							 数量:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.amount}</span>
					 </td>
				 </tr>
				 <tr>
					 <td align="right">
						 <label class="Validform_label">
							 小计:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.productfinalmoney}</span>
					 </td>
					 <td align="right">
						 <label class="Validform_label">
							 补贴类型:
						 </label>
					 </td>
					 <td class="value">
						 <c:if test="${detail.subsidytype != null && detail.subsidytype == 1}">
							 金额
						 </c:if>
						 <c:if test="${detail.subsidytype != null && detail.subsidytype == 2}">
							 折扣
						 </c:if>
						 <c:if test="${detail.subsidytype != null && detail.subsidytype == 3}">
							 满减
						 </c:if>
					 </td>
					 <td align="right">
						 <label class="Validform_label">
							 补贴金额:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.subsidymoney}</span>
					 </td>
				 </tr>
				 <c:if test="${status.index == order.value.size() - 1}">
				 <tr>
					 <td align="right">
						 <label class="Validform_label">
							 订单状态:
						 </label>
					 </td>
					 <td class="value" colspan="6">
						 <input type="hidden" id="order_status_${mapStatus.index}" value="${detail.mallOrderB2cEntity.orderstatus}">
						 <span class="">${detail.mallOrderB2cEntity.orderStatusName}</span>
					 </td>
				 </tr>
					 <tr><td colspan="6" style="text-align: center">收货地址</td></tr>
					 <tr>
						 <td align="right">
							 <label class="Validform_label">
								 收货人:
							 </label>
						 </td>
						 <td class="value">
							 <span class="">${detail.mallOrderB2cEntity.consigneename}</span>
						 </td>
						 <td align="right">
							 <label class="Validform_label">
								 收货人电话:
							 </label>
						 </td>
						 <td class="value">
							 <span class="">${detail.mallOrderB2cEntity.mobilephone}</span>
						 </td>
						 <td align="right">
							 <label class="Validform_label">
								 收货地址:
							 </label>
						 </td>
						 <td class="value" >
							 <span class="">${detail.mallOrderB2cEntity.areacodeStr}${detail.mallOrderB2cEntity.detailaddress}</span>
						 </td>
					 </tr>
				 </c:if>
			 </c:if>
			 <%--本地服务订单--%>
			 <c:if test="${order.key.ordertype == 1}">
				 <tr>
					 <td align="right">
						 <label class="Validform_label">
							 商品名称:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.productname}</span>
					 </td>
					 <td align="right">
						 <label class="Validform_label">
							 商品编码:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.productcode}</span>
					 </td>
					 <td align="right">
						 <label class="Validform_label">
							 数量:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.amount}</span>
					 </td>
				 </tr>
				 <tr>
					 <td align="right">
						 <label class="Validform_label">
							 小计:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.productfinalmoney}</span>
					 </td>
					 <td align="right">
						 <label class="Validform_label">
							 补贴类型:
						 </label>
					 </td>
					 <td class="value">
						 <c:if test="${detail.subsidytype != null && detail.subsidytype == 1}">
							 金额
						 </c:if>
						 <c:if test="${detail.subsidytype != null && detail.subsidytype == 2}">
							 折扣
						 </c:if>
						 <c:if test="${detail.subsidytype != null && detail.subsidytype == 3}">
							 满减
						 </c:if>
					 </td>
					 <td align="right">
						 <label class="Validform_label">
							 补贴金额:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.subsidymoney}</span>
					 </td>
				 </tr>
				 <tr>
					 <td align="right">
						 <label class="Validform_label">
							 订单状态:
						 </label>
					 </td>
					 <td class="value">
						 <input type="hidden" id="order_status_${mapStatus.index}" value="${detail.mallOrderO2oEntity.orderstatus}">
						 <span class="">${detail.mallOrderO2oEntity.orderStatusName}</span>
					 </td>
					 <td align="right">
						 <label class="Validform_label">
							 短信接受手机:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.mallOrderO2oEntity.mobilephone}</span>
					 </td>
					 <td align="right">
						 <label class="Validform_label">
							 消费时间:
						 </label>
					 </td>
					 <td class="value">
						 <span class=""><fmt:formatDate value='${detail.mallOrderO2oEntity.consumetime}' type="date" pattern="yyyy-MM-dd HH:mm:ss"/></span>
					 </td>
				 </tr>
			 </c:if>
			 <%--在线充值服务订单--%>
			 <c:if test="${order.key.ordertype == 2}">
				 <tr>
					 <td align="right">
						 <label class="Validform_label">
							 商品名称:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.productname}</span>
					 </td>
					 <td align="right">
						 <label class="Validform_label">
							 商品编码:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.productcode}</span>
					 </td>
					 <td align="right">
						 <label class="Validform_label">
							 数量:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.amount}</span>
					 </td>
				 </tr>
				 <tr>
					 <td align="right">
						 <label class="Validform_label">
							 小计:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.productfinalmoney}</span>
					 </td>
					 <td align="right">
						 <label class="Validform_label">
							 补贴类型:
						 </label>
					 </td>
					 <td class="value">
						 <c:if test="${detail.subsidytype != null && detail.subsidytype == 1}">
							 金额
						 </c:if>
						 <c:if test="${detail.subsidytype != null && detail.subsidytype == 2}">
							 折扣
						 </c:if>
						 <c:if test="${detail.subsidytype != null && detail.subsidytype == 3}">
							 满减
						 </c:if>
					 </td>
					 <td align="right">
						 <label class="Validform_label">
							 补贴金额:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.subsidymoney}</span>
					 </td>
				 </tr>
				 <tr>
					 <td align="right">
						 <label class="Validform_label">
							 订单状态:
						 </label>
					 </td>
					 <td class="value">
						 <input type="hidden" id="order_status_${mapStatus.index}" value="${detail.mallOrderVirtualEntity.orderstatus}">
						 <span class="">${detail.mallOrderVirtualEntity.orderStatusName}</span>
					 </td>
					 <td align="right">
						 <label class="Validform_label">
							 卡号:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.mallOrderVirtualEntity.cardno}</span>
					 </td>
					 <td align="right">
						 <label class="Validform_label">
							 通知电话:
						 </label>
					 </td>
					 <td class="value">
						 <span class="">${detail.mallOrderVirtualEntity.noticephone}</span>
					 </td>
				 </tr>
			 </c:if>
		  </c:forEach>
			 <%--返点信息--%>
			<c:if test="${mapStatus.index == orderDetail.size() - 1}">
				<tr><td colspan="6" style="text-align: center">返点信息</td></tr>
				<tr>
					<td align="right" >
						<label class="Validform_label">
							订单总金额:
						</label>
					</td>
					<td class="value"  >
						<span class="">${totalMoney}</span>
					</td>
					<td align="right" >
						<label class="Validform_label">
							实际支付总金额:
						</label>
					</td>
					<td class="value"  >
						<span class="">${actualPayTotalMoney}</span>
					</td>
					<td align="right">
						<label class="Validform_label">
							返点类型:
						</label>
					</td>
					<td class="value" >
						<span class="">
							<c:if test="${rebate.rebatetype == 0}">按点返</c:if>
							<c:if test="${rebate.rebatetype == 1}">按金额</c:if>
						</span>
					</td>
				</tr>
				<tr >
					<td align="right">
						<label class="Validform_label">
							返点点数:
						</label>
					</td>
					<td class="value" >
						<span class="">${rebate.rebatenum}</span>
					</td>
					<td align="right">
						<label class="Validform_label">
							返点金额:
						</label>
					</td>
					<td class="value" >
						<span class="">${rebate.rebatemoney}</span>
					</td>
					<td align="right">
						<label class="Validform_label">
							返点时间:
						</label>
					</td>
					<td class="value">
						<span class=""><fmt:formatDate value='${rebate.rebatetime}' type="date" pattern="yyyy-MM-dd HH:mm:ss"/></span>
					</td>
				</tr>
				<tr>
					<td align="right">
						<label class="Validform_label">
							返点操作人:
						</label>
					</td>
					<td class="value" colspan="6">
						<span class="">${rebate.rebateUser.userName}</span>
					</td>
				</tr>
                <tr><td colspan="6" style="text-align: center">返点复核信息</td></tr>
                <tr>
                    <td align="right">
                        <label class="Validform_label">
                            复核结果:
                        </label>
                    </td>
                    <td class="value" >
                        <c:if test="${rebate.rebateauditstate == 0}"><span class="">待复核</span></c:if>
                        <c:if test="${rebate.rebateauditstate == 1}"><span class="">通过</span></c:if>
                        <c:if test="${rebate.rebateauditstate == 2}"><span class="">未通过</span></c:if>
                    </td>
                    <td align="right">
                        <label class="Validform_label">
                            复核人:
                        </label>
                    </td>
                    <td class="value" >
                        <span class="">${rebate.rebateAuditUser.userName}</span>
                    </td>
                    <td align="right">
                        <label class="Validform_label">
                            复核时间:
                        </label>
                    </td>
                    <td class="value" >
                        <span class=""><fmt:formatDate value='${rebate.rebatereviewtime}' type="date" pattern="yyyy-MM-dd HH:mm:ss"/></span>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <label class="Validform_label">
                            未通过原因:
                        </label>
                    </td>
                    <td class="value" >
                        <textarea name="rebaterejectreason"  style="width: 400px;height:100px">${rebate.rebaterejectreason}</textarea>
                    </td>
                </tr>

				<%--显示退回信息--%>
				<c:if test="${rebate.state == 1 || rebate.state == 2}">
                    <tr><td colspan="6" style="text-align: center">退回信息</td></tr>
					<tr>
						<td align="right" >
							<label class="Validform_label">
								退回类型:
							</label>
						</td>
						<td class="value"  >
							<span class="">
								<c:if test="${rebate.state == 1}">部分退回</c:if>
								<c:if test="${rebate.state == 2}">全部退回</c:if>
							</span>
						</td>
						<td align="right">
							<label class="Validform_label">
								退回金额:
							</label>
						</td>
						<td class="value" >
							<span class="" >${rebate.returnmoney}</span>
						</td>
						<td align="right">
							<label class="Validform_label">
								退回时间:
							</label>
						</td>
						<td class="value" >
							<span class="" ><fmt:formatDate value='${rebate.returntime}' type="date" pattern="yyyy-MM-dd HH:mm:ss"/></span>
						</td>
					</tr>
					<tr>
						<td align="right">
							<label class="Validform_label">
								退回操作人:
							</label>
						</td>
						<td class="value">
							<span class="" >${rebate.returnUser.userName}</span>
						</td>
						<td align="right">
							<label class="Validform_label">
								退回原因:
							</label>
						</td>
						<td class="value" colspan="4">
							<textarea name="returnReason" style="width: 400px;height:100px">${rebate.returnreason}</textarea>
							<span class="Validform_checktip"></span>
						</td>
					</tr>
                    <tr><td colspan="6" style="text-align: center">返点退回复核信息</td></tr>
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                复核结果:
                            </label>
                        </td>
                        <td class="value" >
                            <c:if test="${rebate.returnauditstate == 0}"><span class="">待审核</span></c:if>
                            <c:if test="${rebate.returnauditstate == 1}"><span class="">通过</span></c:if>
                            <c:if test="${rebate.returnauditstate == 2}"><span class="">未通过</span></c:if>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                复核人:
                            </label>
                        </td>
                        <td class="value" >
                            <span class="">${rebate.returnAuditUser.userName}</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                复核时间:
                            </label>
                        </td>
                        <td class="value" >
                            <span class=""><fmt:formatDate value='${rebate.returnreviewtime}' type="date" pattern="yyyy-MM-dd HH:mm:ss"/></span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                未通过原因:
                            </label>
                        </td>
                        <td class="value" >
                            <textarea name="returnrejectreason"  style="width: 400px;height:100px">${rebate.returnrejectreason}</textarea>
                        </td>
                    </tr>
				</c:if>
                <%--设置退回信息--%>
                <c:if test="${islook == 0}">
                    <c:if test="${rebate.rebateauditstate == 1 && (rebate.returnauditstate == null || rebate.returnauditstate == 2)}">
                    <tr><td colspan="6" style="text-align: center">设置返点退回信息</td></tr>
                    <tr>
                        <td align="right" >
                            <label class="Validform_label">
                                以返金额:
                            </label>
                        </td>
                        <td class="value"  colspan="6">
                            <input type="hidden" value="${rebate.rebatemoney}" id="rebate_money">
                            <span class="">${rebate.rebatemoney}</span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                退回金额:
                            </label>
                        </td>
                        <td class="value" colspan="6">
                            <input type="text" name="returnmoney"  id="return_money" datatype="money" >
                            <span class="Validform_checktip Validform_wrong" id="error_msg"></span>
                            <input type="button" id="all_return_btn"  value="全部退回"/>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                退回原因:
                            </label>
                        </td>
                        <td class="value" colspan="6">
                            <textarea name="returnreason" datatype="*"  style="width: 400px;height:100px"></textarea>
                            <span class="Validform_checktip"></span>
                        </td>
                    </tr>

                        <tr>
                            <td align="right" >
                                <label class="Validform_label">
                                    <input type="button" id="save"   value="确认"/>
                                </label>
                            </td>
                            <td  colspan="6">
                                <label class="Validform_label">
                                    <input type="button" value="返回" id="back" onclick="javascript:history.back(-1)"/>
                                </label>
                            </td>
                        </tr>
                    </c:if>

                </c:if>
				<c:if test="${islook == 1}">
					<tr>
						<td align="right" >
							<label class="Validform_label">
							</label>
						</td>
						<td  colspan="6" align="left">
							<label class="Validform_label">
								<input type="button" value="返回"  onclick="javascript:history.back(-1)"/>
							</label>
						</td>
					</tr>
				</c:if>
			</c:if>
		 </c:forEach>
	 </table>
 </form>
 </body>
 <script type="text/javascript">
	 $(function() {
		 mallEcardRebateReturnModule.init();
	 });
	 var mallEcardRebateReturnModule = (function(){
		 //表单验证
		 var fromValidform = function(){
			 $("#rebate_return").Validform({
				 tiptype:4,
				 btnSubmit:"#save",
				 ajaxPost:true,
				 datatype :{
					 "money":function(gets,obj,curform,regxp){
						 var rege = /^([1-9]\d*|0)(\.\d{1,2})?$/;
						 if(!rege.test(gets)) {
							 return false;
						 }else{
							 if(parseFloat(gets) == 0){
								 return false;
							 }
						 }
					 }
				 },
				 callback:function(data){
					 if(data.success==true){
						 tip(data.msg);
						 window.document.location.href  = 'mallEcardRebateController.do?list'
					 }else{
						 $.messager.alert('错误',data.msg);
					 }
				 }
			 });
		 }
		 //实时监听input输入
		 var inputChange = function(){
			 $("#return_money").bind('input propertychange', function() {
				 var rebateMoney = parseFloat($("#rebate_money").val());
				 var valid = rebateMoney >= parseFloat($(this).val());
				 if(!valid){
					 $("#error_msg").text("退回金额不能大于以返金额！");
					 $("#error_msg").addClass("Validform_wrong");
					 saveButdisabled(true);
				 }else{
					 $("#error_msg").text("");
					 $("#error_msg").removeClass("Validform_wrong");
					 saveButdisabled(false);
				 }
			 });
		 }
		//全部退回按钮
		 var allReturnBtn = function(){
			 $("#all_return_btn").bind("click", function(){
				 $("#return_money").val($("#rebate_money").val());
			 });
		 }
		 //保存按钮禁用和启用
		 var saveButdisabled = function(disabled){
			 if(disabled){
				 $("#save").prop("disabled", true);
			 }else{
				 $("#save").prop("disabled", false);
			 }
		 }

		 var module = {
			 init : function(){
				 fromValidform();
				 inputChange();
				 allReturnBtn();
			 },
		 }
		 return module;
	 })();

 </script>